﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Newtonsoft.Json;
using Common;

namespace Habito.Admini
{
	public partial class Reference : System.Web.UI.Page
	{
		protected void Page_Load(object sender, EventArgs e)
		{

			if (string.IsNullOrEmpty(Ticket.UserName) || Session["username"] == null)
			{
				Response.Redirect("Login.aspx");
			}
		}

		protected override void OnInit(System.EventArgs e)
		{
			if (Request.QueryString["GetAllReference"] == "1")
			{
				Ajax.BLL.References bll = new Ajax.BLL.References();
				List<Ajax.Model.References> sa = bll.GetModelList("");
				string s = JsonConvert.SerializeObject(sa);
				Response.Write(s);
				Response.End();
			}
			if (Request.QueryString["DeleteReference"] == "1")
			{
				int id = int.Parse(Request.QueryString["id"].Replace("\'", ""));
				Ajax.BLL.References bll = new Ajax.BLL.References();
				bool result = bll.Delete(id); 

				Response.Write(result);
				Response.End();
			}
			base.OnInit(e);
		}
	}
}